import { Component } from '@angular/core';
import {ViewController} from "ionic-angular";

@Component({
  selector: 'g-pay-choose',
  templateUrl: 'g-pay-choose.html'
})
export class GPayChooseComponent {

  result: any;
  list:object[]

  constructor(public viewCtrl: ViewController) {
    this.list = this.viewCtrl.data.bankList
    this.result = this.viewCtrl.data.defaultValue.id
  }

  confirm(){
    let re = this.result
    this.close()
    if(re){
      this.viewCtrl.data.success(this.getResultById())
    }
  }

  getResultById(){
    for (let bank of this.list){
      if(bank['id'] == this.result){
        return bank
      }
    }
  }

  close() {
    this.viewCtrl.dismiss();
  }

}
